home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / frantic.swf / scripts / fl / controls / Button.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  3.3 KB  |  117 lines

  1. package fl.controls
  2. {
  3.    import fl.core.InvalidationType;
  4.    import fl.core.UIComponent;
  5.    import fl.managers.IFocusManagerComponent;
  6.    import flash.display.DisplayObject;
  7.    
  8.    public class Button extends LabelButton implements IFocusManagerComponent
  9.    {
  10.       
  11.       private static var defaultStyles:Object = {
  12.          "emphasizedSkin":"Button_emphasizedSkin",
  13.          "emphasizedPadding":2
  14.       };
  15.       
  16.       public static var createAccessibilityImplementation:Function;
  17.        
  18.       
  19.       protected var emphasizedBorder:DisplayObject;
  20.       
  21.       protected var _emphasized:Boolean = false;
  22.       
  23.       public function Button()
  24.       {
  25.          _emphasized = false;
  26.          super();
  27.       }
  28.       
  29.       public static function getStyleDefinition() : Object
  30.       {
  31.          return UIComponent.mergeStyles(LabelButton.getStyleDefinition(),defaultStyles);
  32.       }
  33.       
  34.       override public function drawFocus(param1:Boolean) : void
  35.       {
  36.          var _loc2_:Number = NaN;
  37.          var _loc3_:* = undefined;
  38.          super.drawFocus(param1);
  39.          if(param1)
  40.          {
  41.             _loc2_ = Number(getStyleValue("emphasizedPadding"));
  42.             if(_loc2_ < 0 || !_emphasized)
  43.             {
  44.                _loc2_ = 0;
  45.             }
  46.             _loc3_ = getStyleValue("focusRectPadding");
  47.             _loc3_ = _loc3_ == null ? 2 : _loc3_;
  48.             _loc3_ += _loc2_;
  49.             uiFocusRect.x = -_loc3_;
  50.             uiFocusRect.y = -_loc3_;
  51.             uiFocusRect.width = width + _loc3_ * 2;
  52.             uiFocusRect.height = height + _loc3_ * 2;
  53.          }
  54.       }
  55.       
  56.       public function set emphasized(param1:Boolean) : void
  57.       {
  58.          _emphasized = param1;
  59.          invalidate(InvalidationType.STYLES);
  60.       }
  61.       
  62.       override protected function draw() : void
  63.       {
  64.          if(isInvalid(InvalidationType.STYLES) || isInvalid(InvalidationType.SIZE))
  65.          {
  66.             drawEmphasized();
  67.          }
  68.          super.draw();
  69.          if(emphasizedBorder != null)
  70.          {
  71.             setChildIndex(emphasizedBorder,numChildren - 1);
  72.          }
  73.       }
  74.       
  75.       public function get emphasized() : Boolean
  76.       {
  77.          return _emphasized;
  78.       }
  79.       
  80.       override protected function initializeAccessibility() : void
  81.       {
  82.          if(Button.createAccessibilityImplementation != null)
  83.          {
  84.             Button.createAccessibilityImplementation(this);
  85.          }
  86.       }
  87.       
  88.       protected function drawEmphasized() : void
  89.       {
  90.          var _loc1_:Object = null;
  91.          var _loc2_:Number = NaN;
  92.          if(emphasizedBorder != null)
  93.          {
  94.             removeChild(emphasizedBorder);
  95.          }
  96.          emphasizedBorder = null;
  97.          if(!_emphasized)
  98.          {
  99.             return;
  100.          }
  101.          _loc1_ = getStyleValue("emphasizedSkin");
  102.          if(_loc1_ != null)
  103.          {
  104.             emphasizedBorder = getDisplayObjectInstance(_loc1_);
  105.          }
  106.          if(emphasizedBorder != null)
  107.          {
  108.             addChildAt(emphasizedBorder,0);
  109.             _loc2_ = Number(getStyleValue("emphasizedPadding"));
  110.             emphasizedBorder.x = emphasizedBorder.y = -_loc2_;
  111.             emphasizedBorder.width = width + _loc2_ * 2;
  112.             emphasizedBorder.height = height + _loc2_ * 2;
  113.          }
  114.       }
  115.    }
  116. }
  117.